<!--
 * @Description: 变更单拆单
 * 
 * @Author: XiongYaoYuan<xiongyaoyuan>
 * @Date: 2023-08-17 22:13:06
 * @FilePath: /yuxiuproweb/src/views/mes/pro/splitOrder/changeIndex.vue
-->

<template>
  <div class="app-container">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="未拆单" name="1"></el-tab-pane>
      <el-tab-pane label="已拆单" name="2"></el-tab-pane>
      <!-- <el-tab-pane label="加工中" name="3"></el-tab-pane>
      <el-tab-pane label="以配货" name="4"></el-tab-pane> -->
      <el-tab-pane label="未打印" name="5"></el-tab-pane>
      <el-tab-pane label="已打印" name="6"></el-tab-pane>
      <el-tab-pane label="全部" name="7"></el-tab-pane>
    </el-tabs>
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="加工单号" prop="proOrderCustomCurtainId">
        <el-input
          v-model="queryParams.proOrderCustomCurtainId"
          placeholder="请输入加工单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发货单号" prop="trackingNumber">
        <el-input
          v-model="queryParams.trackingNumber"
          placeholder="请输入发货单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="客户名" prop="clientName">
        <el-input
          v-model="queryParams.clientName"
          placeholder="请输入客户名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="拆单状态" prop="state">
        <el-select
          v-model="queryParams.state"
          clearable
          placeholder="请选择"
          style="width: 100%"
        >
          <el-option label="未加工" value="0"> </el-option>
          <el-option label="已拆单" value="1"> </el-option>
          <el-option label="加工中" value="2"> </el-option>
          <el-option label="已配货" value="3"> </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="打印状态" prop="isPrint">
        <el-select
          v-model="queryParams.isPrint"
          clearable
          placeholder="请选择"
          style="width: 100%"
        >
          <el-option label="未打印" value="0"> </el-option>
          <el-option label="已打印" value="1"> </el-option>
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="下单时间" prop="createDate">
        <el-date-picker
          clearable
          v-model="queryParams.createDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择下单时间"
          style="width: 100%"
        >
        </el-date-picker>
      </el-form-item> -->
      <el-form-item label="下单时间" prop="createDate">
        <el-date-picker
          align="center"
          style="width: 240px"
          v-model="queryParams.createDateObj"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          format="yyyy-MM-dd"
        >
        </el-date-picker>
      </el-form-item>
      <!-- <el-form-item label="交单时间" prop="submitTime">
        <el-date-picker
          clearable
          v-model="queryParams.submitTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择交单时间"
          style="width: 100%"
        >
        </el-date-picker>
      </el-form-item> -->
      <el-form-item label="交单时间" prop="submitTime">
        <el-date-picker
          align="center"
          style="width: 240px"
          v-model="queryParams.submitTimeObj"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          format="yyyy-MM-dd"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="销售单号" prop="orderId">
        <el-input
          v-model="queryParams.orderId"
          placeholder="请输入销售单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="计划备注" prop="planRemark">
        <el-input
          v-model="queryParams.planRemark"
          placeholder="请输入计划备注"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单备注" prop="orderRemark">
        <el-input
          v-model="queryParams.orderRemark"
          placeholder="请输入订单备注"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="型号" prop="fabricName">
        <el-input
          v-model="queryParams.fabricName"
          placeholder="请输入型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="发货状态" prop="shippingStatus">
        <el-select
          v-model="queryParams.shippingStatus"
          clearable
          placeholder="请选择"
          style="width: 100%"
        >
          <el-option label="未发货" value="0"> </el-option>
          <el-option label="已发货" value="1"> </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-copy-document"
          size="mini"
          @click="handleBatch"
          >批量拆单</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-printer"
          size="mini"
          @click="handleBatchPrint"
          >批量打印工单</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-printer"
          size="mini"
          @click="handleBatchBarCode"
          >批量打印条码</el-button
        >
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['pro:product:export']"
          >导出</el-button
        >
      </el-col> -->
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="productList"
      @selection-change="handleSelectionChange"
      :row-class-name="tableRowClassName"
      :max-height="maxHeight - 50"
      border
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" type="index" width="55" align="center" />
      <el-table-column label="加工单号" align="center" prop="productId">
        <template slot-scope="{ row }">
          <el-link type="primary" @click="handleDetail(row)">{{
            row.productId
          }}</el-link>
        </template>
      </el-table-column>
      <!-- <el-table-column label="销售部" align="center" prop="salesDept" />
      <el-table-column label="品牌" align="center" prop="brand" />
      <el-table-column
        label="加工单号"
        align="center"
        prop="processingOrderNumber"
      /> -->
      <el-table-column label="营销推送" align="center" prop="marketingPush" />

      <el-table-column
        label="客户名"
        align="center"
        prop="clientName"
        width="150"
      />
      <el-table-column
        label="订单备注"
        align="center"
        prop="orderRemark"
        width="150"
      />

      <el-table-column
        label="计划备注"
        align="center"
        prop="remark"
        min-width="200"
      >
        <template slot-scope="{ row }">
          <div
            style="cursor: pointer"
            @click="
              remark = {
                show: true,
                data: {
                  ...row,
                },
              }
            "
          >
            <i class="el-icon-edit"></i>{{ row.remark || "未填写" }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="销售单号"
        align="center"
        prop="salesOrderNumber"
      />
      <el-table-column
        label="订单详情"
        align="center"
        prop="orderDetails"
        min-width="200"
      />
      <el-table-column
        label="下单日期"
        align="center"
        prop="orderDate"
        width="150"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.orderDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="交单日期"
        align="center"
        prop="submitDate"
        width="150"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.submitDate, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="序号" align="center" prop="serialNumber" /> -->
      <el-table-column label="状态" align="center" prop="state">
        <template slot-scope="{ row }">
          <el-link
            type="primary"
            @click="
              () => {
                schedule = {
                  show: true,
                  data: {
                    ...row,
                  },
                };
              }
            "
            >{{ row.state }}</el-link
          >
        </template>
      </el-table-column>
      <el-table-column label="打印状态" align="center" prop="isPrint">
        <template slot-scope="{ row }">
          <span v-if="`${row.isPrint}` === '1'">已打印</span>
          <span v-else style="color: red">未打印</span>
        </template>
      </el-table-column>
      <el-table-column label="最近工序" align="center" prop="processName">
        <template slot-scope="{ row }">
          {{ row.processName ? row.processName.split(",")[0] : "" }}
        </template>
      </el-table-column>
      <el-table-column
        label="工序时间"
        align="center"
        prop="updateTime"
        width="150"
      >
        <template slot-scope="{ row }">
          {{ row.processName ? row.processName.split(",")[1] : "" }}
        </template>
      </el-table-column>
      <el-table-column
        label="工单打印时间"
        align="center"
        prop="orderDate"
        width="150"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.printTimeType0, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="水洗单打印时间"
        align="center"
        prop="orderDate"
        width="150"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.printTimeType1, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="房间" align="center" prop="roomName" />
      <el-table-column
        label="发货单号"
        align="center"
        prop="deliveryNoteNumber"
      />
      <el-table-column
        label="窗帘详情"
        align="center"
        prop="curtainInfo"
        min-width="300"
        show-overflow-tooltip
      />
      <el-table-column
        label="销售备注"
        align="center"
        prop="salesRemark"
        min-width="200"
      />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        min-width="270"
        fixed="right"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-printer"
            :disabled="scope.row.state !== '已拆单'"
            @click="handlePrinter(scope.row)"
            >工单</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-printer"
            :disabled="scope.row.state !== '已拆单'"
            @click="handleBarCode(scope.row)"
            >条码</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleSplitOrder([scope.row.productId])"
            >拆单</el-button
          >
          <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleProductionSplitOrder([scope.row.productId])"
            >工序拆单</el-button
          > -->
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="
              () => {
                production = {
                  show: true,
                  data: {
                    ...scope.row,
                  },
                };
              }
            "
            >修改工序</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 详情 -->
    <detail-view
      v-if="detail.show"
      :show.sync="detail.show"
      v-bind="detail"
    ></detail-view>

    <!-- 打印工单 -->
    <print-view
      v-if="print.show"
      :show.sync="print.show"
      v-bind="print"
    ></print-view>

    <!-- 打印条码 -->
    <bar-code-view
      v-if="barCode.show"
      :show.sync="barCode.show"
      v-bind="barCode"
    ></bar-code-view>

    <!-- 进度 -->
    <schedule-view
      v-if="schedule.show"
      :show.sync="schedule.show"
      v-bind="schedule"
    ></schedule-view>

    <!-- 加工备注 -->
    <edit-remark
      v-if="remark.show"
      :show.sync="remark.show"
      v-bind="remark"
      @on-change="handleRemarkChange"
    ></edit-remark>

    <production-view
      v-if="production.show"
      :show.sync="production.show"
      v-bind="production"
    ></production-view>
  </div>
</template>

<script>
import {
  changeHandling,
  getFactoryOrderInfo,
  splitOrderDZCL,
  getProduct,
  updatePrint,
  updateRemark,
  processSplitOrder,
} from "@/api/asc/split";
import DetailView from "./mods/detail.vue";
import PrintView from "./mods/print.vue";
import BarCodeView from "./mods/barCode.vue";
import ScheduleView from "./mods/schedule.vue";
import ProductionView from "./mods/production.vue";
import EditRemark from "@/views/mes/pro/splitOrder/mods/editRemark.vue";
import commonMix from "@/utils/mixins/common";
import { getBrand } from "@/api/money/brand";

export default {
  name: "Product",
  dicts: [
    "order_curtain_section",
    "md_complex_machining_model_part_1",
    "md_complex_machining_model_part_2",
  ],
  mixins: [commonMix],
  components: {
    DetailView,
    PrintView,
    BarCodeView,
    ScheduleView,
    EditRemark,
    ProductionView,
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 商品列表表格数据
      productList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 100,
        salesDept: null,
        brand: null,
        proOrderCustomCurtainId: null,
        marketingPush: null,
        trackingNumber: null,
        salesOrderNumber: null,
        clientName: null,
        orderDate: null,
        submitDate: null,
        model: null,
        serialNumber: null,
        state: "0",
        roomName: null,
        orderDetails: null,
        salesRemark: null,
        fabricName: null,
        createDateObj: null,
        submitTimeObj: null,
        shippingStatus: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      detail: {
        show: false,
        data: null,
      },
      print: {
        show: false,
        data: null,
      },
      barCode: {
        show: false,
        data: null,
      },
      schedule: {
        show: false,
        data: null,
      },
      remark: {
        show: false,
        data: null,
      },
      selection: [],
      activeName: "1",
      production: {
        show: false,
        data: null,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    tableRowClassName({ row }) {
      if (row.otherState?.includes("0")) {
        return "success-row";
      } else if (row.otherState?.includes("1")) {
        return "warning-row";
      }
      return "";
    },
    handleClick() {
      this.queryParams.pageNum = 1;
      switch (this.activeName) {
        case "1":
          this.queryParams = {
            ...this.queryParams,
            state: "0",
            isPrint: undefined,
            isAll: undefined,
          };
          break;
        case "2":
          this.queryParams = {
            ...this.queryParams,
            state: "1",
            isPrint: undefined,
            isAll: undefined,
          };
          break;
        case "3":
          this.queryParams = {
            ...this.queryParams,
            state: "2",
            isPrint: undefined,
            isAll: undefined,
          };
          break;
        case "4":
          this.queryParams = {
            ...this.queryParams,
            state: "3",
            isPrint: undefined,
            isAll: undefined,
          };
          break;
        case "5":
          this.queryParams = {
            ...this.queryParams,
            state: undefined,
            isPrint: "0",
            isAll: undefined,
          };
          break;
        case "6":
          this.queryParams = {
            ...this.queryParams,
            state: undefined,
            isPrint: "1",
            isAll: undefined,
          };
          break;
        case "7":
          this.queryParams = {
            ...this.queryParams,
            state: undefined,
            isPrint: undefined,
            isAll: "1",
          };
          break;
        default:
          break;
      }
      this.getList();
    },
    handleRemarkChange(data) {
      updateRemark(data).then(() => {
        this.getList();
      });
    },
    /** 查询商品列表列表 */
    getList() {
      this.loading = true;
      const params = {};
      for (const key in this.queryParams) {
        if (Object.hasOwnProperty.call(this.queryParams, key)) {
          params[key] = this.queryParams[key] || undefined;
        }
      }
      params.createDateStart = this.queryParams.createDateObj?.[0] || null;
      params.createDateEnd = this.queryParams.createDateObj?.[1] || null;
      params.submitTimeStart = this.queryParams.submitTimeObj?.[0] || null;
      params.submitTimeEnd = this.queryParams.submitTimeObj?.[1] || null;
      delete params.createDateObj;
      delete params.submitTimeObj;

      changeHandling(params).then((response) => {
        this.productList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        productId: null,
        salesDept: null,
        brand: null,
        processingOrderNumber: null,
        marketingPush: null,
        deliveryNoteNumber: null,
        salesOrderNumber: null,
        clientName: null,
        orderDate: null,
        submitDate: null,
        model: null,
        serialNumber: null,
        state: null,
        roomName: null,
        orderDetails: null,
        salesRemark: null,
        createBy: null,
        createTime: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.handleClick();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.createDateObj = null;
      this.queryParams.submitTimeObj = null;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.productId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
      this.selection = selection;
    },
    // 更改状态
    async updatePrint(proOrderCustomCurtainIds, isPrint, type) {
      try {
        await updatePrint({
          proOrderCustomCurtainIds: proOrderCustomCurtainIds?.join(),
          isPrint,
          type,
        });
        this.getList();
      } catch (e) {
        console.log(e);
      }
    },
    handleDetail(row) {
      this.detail = {
        show: true,
        data: {
          ...row,
        },
      };
    },
    // 打印工单
    handlePrinter(row) {
      if (row?.state !== "已拆单") {
        this.$message.error("只能打印已拆单工单");
        return;
      }
      getFactoryOrderInfo({
        proOrderCustomCurtainId: row.productId,
      }).then(({ data }) => {
        this.updatePrint([row.productId], "1", "0");
        this.print = {
          show: true,
          list: [data],
          // list: [data, data],
          types: {
            md_complex_machining_model_part_1:
              this.dict.type.md_complex_machining_model_part_1,
            md_complex_machining_model_part_2:
              this.dict.type.md_complex_machining_model_part_2,
          },
        };
      });
    },
    // 批量打印工单
    async handleBatchPrint() {
      if (
        this.selection?.filter((e) => e?.state === "已拆单")?.length !==
        this.selection.length
      ) {
        this.$message.error("存在未拆单的工单，请重新选择");
        return;
      }
      const list = await Promise.all(
        this.selection?.map(async (row) => {
          const { data } = await getFactoryOrderInfo({
            proOrderCustomCurtainId: row.productId,
          });
          return [data];
          // return [data, data];
        })
      );
      this.updatePrint(
        this.selection?.map((e) => e.productId),
        "1",
        "0"
      );
      this.print = {
        show: true,
        list: list.flat(),
        types: {
          md_complex_machining_model_part_1:
            this.dict.type.md_complex_machining_model_part_1,
          md_complex_machining_model_part_2:
            this.dict.type.md_complex_machining_model_part_2,
        },
      };
    },
    async getBrand(brandId) {
      if (!brandId) return require("@/assets/images/icon.png");
      const {
        data: { logo },
      } = await getBrand(brandId);
      return logo || require("@/assets/images/icon.png");
    },
    // 打印条码
    async handleBarCode(row) {
      if (row?.state !== "已拆单") {
        this.$message.error("只能打印已拆单工单");
        return;
      }
      const logo = await this.getBrand(row.brandId);
      getProduct(row.productId).then(({ data }) => {
        let list = [];
        if (["0", "1"].includes(data.section)) {
          list = [
            {
              ...data,
              logo,
              zb: data?.fabricList?.find((e) => e.part2 === "-1")?.name || "",
              pb:
                data?.fabricList
                  ?.filter((e) => e.part2 !== "-1")
                  ?.map((e) => e.name)
                  .join("|") || "",
              clientName: row.clientName,
              fp:
                data.section === "3"
                  ? `${data.otherSection}片`
                  : this.getTypeName(
                      this.dict.type.order_curtain_section,
                      data.section
                    ),
            },
          ];
        } else if (["2", "4"].includes(data.section)) {
          list = [
            {
              ...data,
              logo,
              zb: data?.fabricList?.find((e) => e.part2 === "-1")?.name || "",
              pb:
                data?.fabricList
                  ?.filter((e) => e.part2 !== "-1")
                  ?.map((e) => e.name)
                  .join("|") || "",
              clientName: row.clientName,
              fp:
                data.section === "3"
                  ? `${data.otherSection}片`
                  : this.getTypeName(
                      this.dict.type.order_curtain_section,
                      data.section
                    ),
            },
            {
              ...data,
              logo,
              zb: data?.fabricList?.find((e) => e.part2 === "-1")?.name || "",
              pb:
                data?.fabricList
                  ?.filter((e) => e.part2 !== "-1")
                  ?.map((e) => e.name)
                  .join("|") || "",
              clientName: row.clientName,
              fp:
                data.section === "3"
                  ? `${data.otherSection}片`
                  : this.getTypeName(
                      this.dict.type.order_curtain_section,
                      data.section
                    ),
            },
          ];
        } else if (data.section === "3") {
          list = [];
          for (let i = 0; i < +data.otherSection; i++) {
            list.push({
              ...data,
              logo,
              zb: data?.fabricList?.find((e) => e.part2 === "-1")?.name || "",
              pb:
                data?.fabricList
                  ?.filter((e) => e.part2 !== "-1")
                  ?.map((e) => e.name)
                  .join("|") || "",
              clientName: row.clientName,
              fp:
                data.section === "3"
                  ? `${data.otherSection}片`
                  : this.getTypeName(
                      this.dict.type.order_curtain_section,
                      data.section
                    ),
            });
          }
        }
        this.updatePrint([row.productId], "1", "1");
        this.barCode = {
          show: true,
          list,
        };
      });
    },
    async handleBatchBarCode() {
      if (
        this.selection?.filter((e) => e?.state === "已拆单")?.length !==
        this.selection.length
      ) {
        this.$message.error("存在未拆单的工单，请重新选择");
        return;
      }
      const list = await Promise.all(
        this.selection?.map(async (row) => {
          const logo = await this.getBrand(row.brandId);
          const { data } = await getProduct(row.productId);
          const map = {
              0: 1,
              1: 1,
              2: 2,
              4: 2,
              3: +data.otherSection,
            },
            tmpList = [];
          for (let i = 0; i < map?.[data.section]; i++) {
            tmpList.push({
              ...data,
              logo,
              zb: data?.fabricList?.find((e) => e.part2 === "-1")?.name || "",
              pb:
                data?.fabricList
                  ?.filter((e) => e.part2 !== "-1")
                  ?.map((e) => e.name)
                  .join("|") || "",
              clientName: row.clientName,
              fp:
                data.section === "3"
                  ? `${data.otherSection}片`
                  : this.getTypeName(
                      this.dict.type.order_curtain_section,
                      data.section
                    ),
            });
          }
          return tmpList;
        })
      );
      this.updatePrint(
        this.selection?.map((e) => e.productId),
        "1",
        "1"
      );
      this.barCode = {
        show: true,
        list: list.flat(),
      };
    },
    // 拆单
    handleSplitOrder(ids) {
      splitOrderDZCL(ids.join()).then((res) => {
        this.$message.success("操作成功");
        this.getList();
      });
    },
    // 批量拆单
    handleBatch() {
      this.handleSplitOrder(this.ids);
    },

    // 工序拆单
    handleProductionSplitOrder(ids) {
      this.loading = true;
      processSplitOrder(ids.join()).then((res) => {
        this.$message.success("操作成功");
        this.getList();
        this.loading = false;
      });
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "pro/product/export",
        {
          ...this.queryParams,
        },
        `product_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>

<style scoped lang="scss">
::v-deep {
  .el-table .warning-row {
    background: #b3d8ff;
  }

  .el-table .success-row {
    background: #fbc4c4;
  }
}
</style>
